﻿using System.Windows.Forms;
using Raider.WinForms.Actions.Demo.Properties;
using System.ComponentModel;
using System;
using Raider.WinForms.Actions.Linkage;
using System.Drawing;

namespace Raider.WinForms.Actions.Demo
{
    class CustomAction : ControlAction
    {
        private bool showToolTip = false;

        public CustomAction()
            : base("Custom Action Example", image: Resources.Puzzle)
        {
        }

        // Example of custom property linked with ToolStripItem's AutoToolTip property.
        [LinkWithProperty("AutoToolTip", typeof(ToolStripItem))]
        public bool ShowToolTip
        {
            get { return showToolTip; }
            set { showToolTip = value; OnPropertyChanged("ShowToolTip"); }
        }

        // Example of method linked with ToolStripItem's MouseEnter event.
        [LinkWithEvent("MouseEnter", typeof(ToolStripItem))]
        private void OnMouseEnter(object sender, EventArgs e)
        {
            var item = (ToolStripItem)sender;
            item.ForeColor = Color.Green;
        }

        // Example of method linked with ToolStripItem's MouseLeave event.
        [LinkWithEvent("MouseLeave", typeof(ToolStripItem))]
        private void OnMouseLeave(object sender, EventArgs e)
        {
            var item = (ToolStripItem)sender;
            item.ForeColor = SystemColors.ControlText;
        }

        // Example of overriding action's OnExecute method.
        protected override void OnExecute(ExecuteEventArgs args)
        {
            base.OnExecute(args);
            MessageBox.Show("Hello from " + GetType().Name + "!");
        }
    }
}
